﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;

namespace QLKS.Views
{
    /// <summary>
    /// Interaction logic for ucDmTuyChon.xaml
    /// </summary>
    public partial class ucDmTuyChon : UserControl
    {
        public ucDmTuyChon()
        {
            InitializeComponent();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            mainContent.StringBrowse = "matuychon:Mã số:50;tentuychon:Tên tùy chọn:250;heso:Hệ số:70;soluong:Số lượng:50";
            mainContent.TableSource = ViewModels.TuyChonViewModel.GetDmTuyChon();
            mainContent.F3 += new ucDmTemplate.GridKeyUp_F3(PressKey_F3);
        }

        void PressKey_F3(object sender, EventArgs e)
        {
            DataTable tb = mainContent.CurentRow;
            if (tb == null)
                return;
            frmThemTuyChon frm = new frmThemTuyChon(tb, Command.Edit);
            frm.ShowDialog();
            if (frm.UpdateSucces)
                mainContent.Update(ViewModels.TuyChonViewModel.GetDmTuyChon());
        }
    }
}
